/**
 * 教师管理API
 */
import request from '@/utils/request'

export default {
  /**
   * 获取教师列表
   * @param {Object} params 查询参数 {keyword, department, status, page, page_size}
   * @returns Promise
   */
  getTeacherList(params) {
    return request({
      url: '/admin/teachers',
      method: 'get',
      params
    })
  },

  /**
   * 创建教师
   * @param {Object} data 教师信息 {name, work_number, phone, email, department, title, is_admin, status, bio, password}
   * @returns Promise
   */
  createTeacher(data) {
    return request({
      url: '/admin/teachers',
      method: 'post',
      data
    })
  },

  /**
   * 更新教师信息
   * @param {Object} data 教师信息 {id, name, phone, email, department, title, is_admin, status, bio}
   * @returns Promise
   */
  updateTeacher(data) {
    return request({
      url: `/admin/teachers/${data.id}`,
      method: 'put',
      data
    })
  },

  /**
   * 更新教师状态
   * @param {Object} data {id, status}
   * @returns Promise
   */
  updateTeacherStatus(data) {
    return request({
      url: `/admin/teachers/${data.id}/status`,
      method: 'put',
      data: { status: data.status }
    })
  },

  /**
   * 删除教师
   * @param {number} id 教师ID
   * @returns Promise
   */
  deleteTeacher(id) {
    return request({
      url: `/admin/teachers/${id}`,
      method: 'delete'
    })
  },

  /**
   * 获取教师详情
   * @param {number} id 教师ID
   * @returns Promise
   */
  getTeacherDetail(id) {
    return request({
      url: `/admin/teachers/${id}`,
      method: 'get'
    })
  },

  /**
   * 重置教师密码
   * @param {Object} data {id, password}
   * @returns Promise
   */
  resetPassword(data) {
    return request({
      url: `/admin/teachers/${data.id}/password`,
      method: 'put',
      data: { password: data.password }
    })
  }
}
